import axios from "axios";

// import Qs from "qs";

// let host = window.location.protocol + "//" + window.location.hostname;

export let baseURL = "https://xy.cozzia.com.cn";
// export let baseURL = 'https://wxchart.cozzia.com.cn'
export let DevEnv = !(window.location.hostname.indexOf("cozzia") > -1);
// export let baseURL = "http://192.168.84.102:88";

let VIX_Axios = axios.create({
  baseURL,
});
VIX_Axios.defaults.timeout = 6000;

VIX_Axios.defaults.withCredentials = true;

// 请求拦截
VIX_Axios.interceptors.request.use(
  (config) => {
    // if (config.method === "post") {
    //   config.data = Qs.stringify(config.data);
    // }
    return config;
  },
  (err) => {}
);

// 响应拦截
VIX_Axios.interceptors.response.use(
  (res) => {
    return res.data || res;
  },
  (err) => {
    if (err && err.response) {
      console.log(err);
      switch (err.response.status) {
        default:
          console.log("其他错误信息");
      }
    }
    return err;
  }
);

export default VIX_Axios;
